<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <title>闲置物品订单</title>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <link rel="stylesheet" href="../../xznstatic/css/common.css"/>
    <link rel="stylesheet" href="../../xznstatic/css/style.css"/>
    <script type="text/javascript" src="../../xznstatic/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="../../xznstatic/js/jquery.SuperSlide.2.1.1.js"></script>
    <link rel="stylesheet" href="../../xznstatic/css/bootstrap.min.css" />

    <link rel="stylesheet" href="../../css/theme.css"/>
</head>
<style>
    .center-container {
        width: 1200px;
        margin: 0 auto;
        margin-top: 20px;
        display: flex;
        margin-bottom: 20px;
    }
    .index-sec1{ height: auto; width: 20%;background-color: #fff}
    .sec1-left{ width: 100%; height: auto; margin-top: 10px; padding-left: 17px;}
    .sec1-left ul{ margin-top: 20px;}
    .sec1-left li{ transition: all 0.6s; height: 45px; border-bottom: 1px solid #d8d8d8; margin:15px 0px; width: 70%; line-height: 45px;}
    .sec1-left li{  font-size: 15px; color: #333; height: 45px; line-height: 45px; transition: all 0.6s;background-color: var(--publicSubColor)}
    .sec1-left .p1{ font-size: 20px; color: #333333; font-weight: bold; font-family: arial; text-transform: uppercase;line-height: 1; margin-top: 20px;}
    .sec1-left .p2{ font-size: 22px; color: #333333; padding: 25px 0 0 0; line-height: 1;}
    .sec1-left .p2 b{ display: block; width: 31px; background: #666; height: 1px; margin-top: 30px;}
    .sec1-left li i{ display: inline-block;font-size: 25px; width: 10px; transition: all 0.6s;
        margin-right: 20px; vertical-align:-3px; margin-left: 5px;}
    .sec1-left li:hover i,.sec1-left li.on i{ background-position: -85px -42px;}
    .sec1-left li span{ display: inline-block; height: 1px; width: 5px; background: #666; vertical-align:middle; margin-right: 10px; transition: all 0.6s;}
    .sec1-left li:hover b,.sec1-left li:hover,
    .sec1-left li.on b,.sec1-left li.on{ color: #fff;}
    .sec1-left li:hover span,.sec1-left li.on  span{ background: #fff; width: 22px;}
    .sec1-left li:hover,.sec1-left li.on{ font-size: 17px;background: var(--publicMainColor);width: 90%; border-bottom-color: var(--publicMainColor);}
    ul, li {list-style: none;margin: 0;padding: 0;}
    a {text-decoration: none;}
    p{margin: 0;padding: 0;}
    i {font-style: normal;}</style>
<body class='bodyClass'>
<div id="app">
<!-- 标题 -->

    <el-dialog title="评论" :visible.sync="shangpinCommentbackModal" :modal-append-to-body="false">
        <el-form>
            <el-form-item label="评论信息">
                <el-input type="textarea" v-model="shangpinCommentbackContent"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="shangpinCommentbackModal = false">取 消</el-button>
            <el-button type="primary" @click="submitShangpinCommentback()">确 定</el-button>
        </div>
    </el-dialog>

    <!-- 标题 -->
    <div class="center-container">
        <!-- 个人中心菜单 config.js-->
<div class="index-sec1">
    <div class="sec1-left fl">
        <p class="p1">USER / CENTER</p>
        <p class="p2">闲置物品订单<b></b></p>
        <ul>
            <li v-for="(item,index) in centerMenu" v-bind:key="index" :class="item.url=='../shangpinOrder/list.html'?'on':''" @click="jump(item.url)">
                <i class="layui-icon">&#xe756;</i><span></span>{{item.name}}
            </li>
        </ul>
    </div>
</div>        <!-- 个人中心菜单 -->
        <div class="right-container sub_borderColor" :style='{"padding":"20px","boxShadow":"0px rgba(255,0,0,.8)","margin":"0","backgroundColor":"#fff","borderRadius":"0","borderWidth":"1px","borderStyle":"solid","width":"80%"}'>
            <div style="display: flex;height: 60px;align-items: center;margin-left: 15px;">
                <div style="display: flex;height: 60px;align-items: center;margin-left: 15px;">
                    <div class="thisTableType-search" style="margin-left: 15px;"
                         :style='searchForm.shangpinOrderTypes=="" || searchForm.shangpinOrderTypes==null?{"color":"red","borderBottom":"1px solid red"}:{"color":"#000"}'>
                        全部
                    </div>
                    <div style="margin-left: 15px;" v-for="item in shangpinOrderTypesList" :index="item.codeIndex" class="thisTableType-search"
                         :style='searchForm.shangpinOrderTypes==item.codeIndex?{"color":"red","borderBottom":"1px solid red"}:{"color":"#000"}'>
                        {{item.indexName}}
                    </div>
                </div>
            </div>
            <div style="width: 90%;height: 40px;margin: 0 auto;display: flex;background-color: #f3f3f3;line-height: 40px;;text-align: center">
                <div style="width: 33%">
                    订单详情
                </div>
                <div style="width: 25%">
                    地址/收货人
                </div>
                <div style="width: 19%">
                    金额
                </div>
                <div style="width: 6%">
                    状态
                </div>
                <div style="width: 16%">
                    操作
                </div>
            </div>
            <div style="width: 90%;margin: 0 auto;border: 1px solid #f3f3f3;margin-top: 15px;"
                 v-for="(item,index) in dataList" v-bind:key="index">
                <div
                        style="height: 40px;background-color: #f3f3f3;display: flex;    align-items: center;">
                    <div style="margin-left: 15px;">
                        {{item.insertTime}}
                    </div>
                    <div style="margin-left: 50px;">
                        订单号:{{item.shangpinOrderUuidNumber}}
                    </div>
                    <div style="margin-left: 50px;" v-if="item.shangpinOrderTypes == 3 && item.shangpinOrderCourierName != null">
                        {{item.shangpinOrderCourierName}}：{{item.shangpinOrderCourierNumber}}
                    </div>
                     <div style="margin-left: 35px;">
                        购买用户:{{item.yonghuName}}
                    </div>
                </div>
                <div style="display: flex;">
                    <div style="width: 60%;display: flex;">
                        <div style="display: flex;">
                            <img :src="baseUrl+item.shangpinPhoto"
                                 style="width: 100px;height: 100px;object-fit: cover;margin: 15px;">
                            <div style="margin: 15px;">
                                <div style="font-size: 14px;">
                                    {{item.shangpinName}}
                                </div>
                                <div style="font-size: 12px;color: #666;">
                                    {{item.shangpinValue}}
                                </div>
                            </div>
                        </div>
                                <div style="margin: 15px;">
                                    x{{item.buyNumber}}
                                </div>
                               <div style="margin: 7px;width: 80px;height: 100px;font-size: 12px;overflow: hidden">
                                   {{item.addressDizhi}}
                               </div>
                    </div>
                    <div style="width: 10%;margin: 15px;">
                            {{item.addressName}}
                            <div>
                                {{item.addressPhone}}
                            </div>
                    </div>
                    <div style="width: 10%;margin: 15px;">
                        {{item.shangpinOrderTruePrice}}
                        <div>{{item.shangpinOrderPaymentValue}}</div>
                    </div>
                    <div style="width: 10%;margin: 15px;">
                        {{item.shangpinOrderValue}}
                    </div>
                    <div style="width: 10%;margin: 15px;">
                        <button v-if="item.shangpinOrderTypes==101 && user.id == item.yonghuId" @click="refund(item.id)" type="button" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-warm">
                            <i class="layui-icon">&#xe65e;</i> 退款
                        </button>
                        <button v-if="item.shangpinOrderTypes==104 && user.id == item.yonghuId" @click="commentback(item.id)" type="button" class="layui-btn layui-btn-sm layui-btn-radius btn-theme">
                            <i class="layui-icon">&#xe65e;</i> 评价
                        </button>
                        <button v-if="item.shangpinOrderTypes==103 && user.id == item.yonghuId" @click="receiving(item.id)" type="button" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-warm">
                            <i class="layui-icon">&#xe65e;</i> 收货
                        </button>
                        <button v-if="item.shangpinOrderTypes==101 && user.id == item.shangpinYonghuId" @click="deliver(item.id)" type="button" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-warm">
                            <i class="layui-icon">&#xe65e;</i> 发货
                        </button>
                    </div>
                </div>
            </div>
            <div class="pager" id="pager" :style="{textAlign:'center'}"></div>
        </div>
    </div></div>

<script src="../../xznstatic/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../layui/layui.js"></script>
<script src="../../js/vue.js"></script>
<!-- 引入element组件库 -->
<script src="../../xznstatic/js/element.min.js"></script>
<!-- 引入element样式 -->
<link rel="stylesheet" href="../../xznstatic/css/element.min.css">
<script src="../../js/config.js"></script>
<script src="../../modules/config.js"></script>
<script src="../../js/utils.js"></script>

<script type="text/javascript">
    Vue.prototype.myFilters = function (msg) {
        if(msg==null || msg==""){
            return "";
        }else if (msg.length>20){
            msg.replace(/\n/g, "<br>");
            return msg.substring(0,30)+"......";
        }else{
            return msg.replace(/\n/g, "<br>");
        }
    };
    var vue = new Vue({
        el: '#app',
        data: {
            //小菜单
            centerMenu: centerMenu,
            //项目路径
            baseUrl:"",
            user:null,
            shangpinOrderTypesList: [],
            shangpinOrderPaymentTypesList: [],
            //评价
			//操作数据id
			shangpinOrderId:null,
			//评价内容
			shangpinOrderContent:null,
			//模态框状态
			shangpinOrderModal:false,
			//评分
		    shangpinOrderCommentbackPingfenNumber:0,
            //查询条件
            searchForm: {
                page: 1
                ,limit: 8
                ,sort: "id"//字段
                ,order: "desc"//asc desc
                        ,shangpinOrderUuidNumber: ""
                ,shangpinOrderTypes: ""
                ,shangpinOrderPaymentTypes: ""
            },

            //订单评论模态框
            shangpinCommentbackContent: null,
            shangpinCommentbackId: null,
            shangpinCommentbackModal: false,
            shangpinCommentbackPingfenNumber:0,

            dataList: [],
        },
        filters: {
            subString: function(val) {
                if (val) {
                    val = val.replace(/<[^<>]+>/g, '').replace(/undefined/g, '');
                    if (val.length > 60) {
                        val = val.substring(0, 60);
                        val+='...';
                    }
                    return val;
                }
                return '';
            }
        },
        computed: {
        },
        methods: {
            isAuth(tablename, button) {
                return isFrontAuth(tablename, button);
            },
            jump(url) {
                jump(url);
            },
            jumpCheck(url,check1,check2) {
                if(check1 == "2" || check1 == 2){//级联表的逻辑删除字段[1:未删除 2:已删除]
                    layui.layer.msg("已经被删除", {
                        time: 2000,
                        icon: 2
                    });
                    return false;
                }
                if(check2 == "2"  || check2 == 2){//是否下架[1:上架 2:下架]
                    layui.layer.msg("已经下架", {
                        time: 2000,
                        icon: 2
                    });
                    return false;
                }
                this.jump(url);
            },
            showContent(content) {alert(content)},
            deleteData(data){
                var mymessage = confirm("确定要删除这条数据吗？");
                if(!mymessage){
                    alert("已取消操作");
                    return false;
                }
                // 获取商品详情信息
                layui.http.requestJson(`shangpinOrder/delete`, 'post', [data.id], (res) => {
                    if(res.code==0){
                        layer.msg('操作成功', {
                            time: 2000,
                            icon: 6
                        });
                        window.location.reload();
                    }else{
                        layer.msg(res.msg, {
                            time: 2000,
                            icon: 2
                        });
                    }
                });
            },
            // 退款
            refund(id) {
                var mymessage = confirm("确定要退款吗？");
                if(!mymessage){alert("已取消操作");return false;}
                // 获取商品详情信息
                layui.http.request(`shangpinOrder/refund?id=`+id, 'get', {}, (res) => {
                    if(res.code==0){
                        layer.msg('退款成功', {time: 2000,icon: 6});
                        window.location.reload();
                    }else{
                        layer.msg(res.msg, {time: 2000,icon: 2});
                    }
                });
            },

            deliver(id){
                var mymessage = confirm("确定要发货吗？");
                if(!mymessage){alert("已取消操作");return false;}
                layui.http.request(`shangpinOrder/deliver?id=`+id, 'get', {}, (res) => {
                    if(res.code==0){
                        layer.msg('操作成功', {time: 2000,icon: 6});
                        window.location.reload();
                    }else{
                        layer.msg(res.msg, {time: 2000,icon: 2});
                    }
                });
            },
            // 收货
            receiving(id) {
                var mymessage = confirm("确定要收货吗？");
                if(!mymessage){alert("已取消操作");return false;}
                layui.http.request(`shangpinOrder/receiving?id=`+id, 'get', {}, (res) => {
                    if(res.code==0){
                        layer.msg('成功收货', {time: 2000,icon: 6});
                        window.location.reload();
                    }else{
                        layer.msg(res.msg, {time: 2000,icon: 2});
                    }
                });
            },
            // 打开评价模态框
            commentback(id) {
                this.shangpinCommentbackContent = null//置空评价内容
                this.shangpinCommentbackId = id//设置订单id
                this.shangpinCommentbackModal = true//打开模态框
            },
            // 提交评价
            submitShangpinCommentback(){
                 if(this.shangpinCommentbackContent == null || this.shangpinCommentbackContent == "" || this.shangpinCommentbackContent == "null"){
                    layer.msg("评价内容不能为空", {time: 2000,icon: 2});
                    return false;
                }
                let _this = this
                layui.http.request("shangpinOrder/commentback?id="+this.shangpinCommentbackId+"&commentbackText="+this.shangpinCommentbackContent + "&shangpinCommentbackPingfenNumber="+this.shangpinCommentbackPingfenNumber, 'get', {}, function (res) {
                    if(res.code==0){
                        layer.msg('评价成功', {time: 2000,icon: 6});
                        window.location.reload();
                    }else{
                        layer.msg(res.msg, {time: 2000,icon: 2});
                    }
                    _this.shangpinCommentbackModal = false
                });
            },

        }
    });

    layui.use(['layer', 'element', 'carousel', 'laypage', 'http', 'jquery', 'laydate', 'tinymce'], function() {
        var layer = layui.layer;
        var element = layui.element;
        var carousel = layui.carousel;
        var laypage = layui.laypage;
        var http = layui.http;
        var laydate = layui.laydate;
        var tinymce = layui.tinymce;
        window.jQuery = window.$ = jquery = layui.jquery;

        localStorage.setItem("goUtl","./pages/shangpinOrder/list.html")


        http.request("yonghu/session", 'get', {}, function (data) {
            vue.user = data.data
        });


        vue.baseUrl = http.baseurl
        // var id = http.getParam('id');

        //订单类型的动态搜素
        $(document).on("click", ".thisTableType-search", function (e) {
            vue.searchForm.shangpinOrderTypes = $(this).attr('index');
            pageList();
        });


            //当前表的 订单类型 字段 字典表查询
            shangpinOrderTypesSelect();
                                                                           //当前表的 订单类型 字段 字典表查询方法
           function shangpinOrderTypesSelect() {
               http.request("dictionary/page?page=1&limit=100&sort=&order=&dicCode=shangpin_order_types", 'get', {}, function (res) {
                   if(res.code == 0){
                       vue.shangpinOrderTypesList = res.data.list;
                   }
               });
           }
                        

            // 分页列表
            pageList();

            // 搜索按钮
            jquery('#btn-search').click(function (e) {
                pageList();
            });

            function pageList() {
                // 获取列表数据
                http.request('shangpinOrder/page', 'get', vue.searchForm, function (res) {
                    vue.dataList = res.data.list;
                    // 分页
                    laypage.render({
                        elem: 'pager',
                        count: res.data.total,
                        limit: vue.searchForm.limit,
                        groups: 3,
                        layout: ["prev", "page", "next"],
                        jump: function (obj, first) {
                            vue.searchForm.page = obj.curr;//翻页
                            //首次不执行
                            if (!first) {
                                http.request('shangpinOrder/page', 'get', vue.searchForm, function (res1) {
                                    vue.dataList = res1.data.list;
                                })
                            }
                        }
                    });
                });
            }
    });

    window.xznSlide = function () {
        jQuery(".banner").slide({mainCell: ".bd ul", autoPlay: true, interTime: 5000});
        jQuery("#ifocus").slide({
            titCell: "#ifocus_btn li",
            mainCell: "#ifocus_piclist ul",
            effect: "leftLoop",
            delayTime: 200,
            autoPlay: true,
            triggerTime: 0
        });
        jQuery("#ifocus").slide({titCell: "#ifocus_btn li", mainCell: "#ifocus_tx ul", delayTime: 0, autoPlay: true});
        jQuery(".product_list").slide({
            mainCell: ".bd ul",
            autoPage: true,
            effect: "leftLoop",
            autoPlay: true,
            vis: 5,
            trigger: "click",
            interTime: 4000
        });
    };
</script>
</body>
</html>
